package com.study.entity.common;

import java.io.Serializable;

import com.study.enumeration.ResponseEnum;

public class CommonResponseEntity<T> implements Serializable {

	private static final long serialVersionUID = 3034559583501211718L;

	/**
	 * 状态码
	 */
	private Integer code;

	/**
	 * 状态码对应信息
	 */
	private String msg;

	/**
	 * 要返回的数据
	 */
	private T data;

	public CommonResponseEntity() {
		super();
	}

	/**
	 * @param code 响应码
	 * @param msg  响应信息
	 */
	public CommonResponseEntity(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	/**
	 * @param code 响应码
	 * @param msg  相应信息
	 * @param data 数据
	 */
	public CommonResponseEntity(Integer code, String msg, T data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	/**
	 * @param responseEnum 自定义枚举类，包含code和msg
	 */
	public CommonResponseEntity(ResponseEnum responseEnum) {
		super();
		this.code = responseEnum.getCode();
		this.msg = responseEnum.getMsg();
	}

	/**
	 * @param responseEnum 自定义枚举类，包含code和msg
	 * @param data         数据
	 */
	public CommonResponseEntity(ResponseEnum responseEnum, T data) {
		super();
		this.code = responseEnum.getCode();
		this.msg = responseEnum.getMsg();
		this.data = data;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
